<?php
/**
 * SocialEngine
 *
 * @category   Application_Core
 * @package    User
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.com/license/
 * @version    $Id: index.tpl 9915 2013-02-15 01:30:19Z alex $
 * @author     John
 */
?>

<h2>
  <?php echo $this->translate("Manage Tours") ?>
</h2>

<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
    // Render the menu
    //->setUlClass()
    echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>

<p>
  <?php echo $this->translate("Description") ?>
</p>
<br />
<a href="<?php echo $this->url(array('module' => 'tourism', 'controller' => 'tours', 'action' => 'create'), 'admin_default', true)?>" > <strong> Create new tour </strong></a>
<br />

<script type="text/javascript">
  var currentOrder = '<?php echo $this->order ?>';
  var currentOrderDirection = '<?php echo $this->order_direction ?>';
  var changeOrder = function(order, default_direction){
    // Just change direction
    if( order == currentOrder ) {
      $('order_direction').value = ( currentOrderDirection == 'ASC' ? 'DESC' : 'ASC' );
    } else {
      $('order').value = order;
      $('order_direction').value = default_direction;
    }
    $('filter_form').submit();
  }

  function multiModify()
  {
    var multimodify_form = $('multimodify_form');
    if (multimodify_form.submit_button.value == 'delete')
    {
      return confirm('<?php echo $this->string()->escapeJavascript($this->translate("Are you sure you want to delete the selected user accounts?")) ?>');
    }
  }

  function selectAll()
  {
    var i;
    var multimodify_form = $('multimodify_form');
    var inputs = multimodify_form.elements;
    for (i = 1; i < inputs.length - 1; i++) {
      if (!inputs[i].disabled) {
        inputs[i].checked = inputs[0].checked;
      }
    }
  }
</script>

<div class='admin_search'>
  <?php echo $this->formFilter->render($this) ?>
</div>

<br />

<div class='admin_results'>
  <div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s tour found", "%s tours found", $count),
      $this->locale()->toNumber($count)) ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
</div>

<br />

<div class="admin_table_form">
  <form id='multimodify_form' method="post" action="<?php echo $this->url(array('action'=>'multi-modify'));?>" onSubmit="multiModify()">
    <table class='admin_table'>
      <thead>
      <tr>
        <th style='width: 1%;'><input onclick="selectAll()" type='checkbox' class='checkbox'></th>
        <th style='width: 1%;'><a href="javascript:void(0);" onclick="javascript:changeOrder('tour_id', 'DESC');"><?php echo $this->translate("ID") ?></a></th>
        <th><a href="javascript:void(0);" onclick="javascript:changeOrder('title', 'ASC');"><?php echo $this->translate("Title") ?></a></th>
        <th class='admin_table_centered'><?php echo $this->translate("Description") ?></th>
        <th class='admin_table_centered'><?php echo $this->translate("Price") ?></th>
        <th style='width: 1%;' class='admin_table_options'><?php echo $this->translate("Options") ?></th>
      </tr>
      </thead>
      <tbody>

      <?php if( count($this->paginator) ): ?>
        <?php foreach( $this->paginator as $item ):
          ?>
          <tr>
            <td><input name='modify_<?php echo $item->getIdentity();?>' value="<?php echo $item->getIdentity();?>" type='checkbox' class='checkbox'></td>
            <td><?php echo $item->tour_id ?></td>
            <td class='admin_table_bold'>
              <?php echo $this->htmlLink($item->getHref(),
                $this->string()->truncate($item->getTitle(), 10),
                array('target' => '_blank'))?>
            </td>
            <td class='admin_table_centered'>
              <?php echo html_entity_decode($item->description) ?>
            </td>
            <td class='admin_table_centered'>
              <?php echo $item->price ?>
            </td>
            <td class='admin_table_options'>
              <a class='smoothbox' href='<?php echo $this->url(array('action' => '', 'id' => $item->tour_id));?>'>
                <?php echo $this->translate("stats") ?>
              </a>
              |
              <a href='<?php echo $this->url(array('action' => 'edit', 'id' => $item->tour_id));?>'>
                <?php echo $this->translate("edit") ?>
              </a>
              |
              <a href='<?php echo $this->url(array('action' => 'delete', 'id' => $item->tour_id));?>'>
                <?php echo $this->translate("delete") ?>
              </a>
            </td>
          </tr>
        <?php endforeach; ?>
      <?php endif; ?>
      </tbody>
    </table>
    <br />
    <div class='buttons'>
      <button type='submit' name="submit_button" value="approve"><?php echo $this->translate("Approve Selected") ?></button>
      <button type='submit' name="submit_button" value="delete" style="float: right;"><?php echo $this->translate("Delete Selected") ?></button>
    </div>
  </form>
</div>